import React, {Component} from 'react';
import LifeComponent from "./LifeComponent";

class Parent extends Component {
  state = {
    value: '',
    isShow: true
  };

  render() {
    return (
      <div>
        <input type="text" onChange={(ev) => {
          this.setState({
            value: ev.target.value
          })

        }}/>

        <button onClick={()=>{
          this.setState({
            isShow: false
          })
        }}>卸载LifeComponent</button>

        <h1>子组件</h1>
        {this.state.isShow && <LifeComponent value={this.state.value}/>}
      </div>
    );
  }
}

export default Parent;
